/*
 * Copyright 2009 Michal Trzcinka
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed
 * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
 * CONDITIONS OF ANY KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations under the License.
 */
function confirm(text, yesHandler) {
  var dialog = new YAHOO.widget.SimpleDialog("dlg", {
    width: "20em",
    fixedcenter:true,
    modal:true,
    visible:false,
    draggable:false
  });
  dialog.setHeader(I18n.t('popup.confirm.title'));
  dialog.setBody(text);
  dialog.cfg.setProperty("icon", YAHOO.widget.SimpleDialog.ICON_WARN);
  var handleYes = function() {
    yesHandler();
    this.hide();
  };
  var handleNo = function() {
    this.hide();
  };
  var myButtons = [ {
    text: I18n.t('popup.confirm.c_yes'),
    handler:handleYes
  },

  {
    text: I18n.t('popup.confirm.c_no'),
    handler:handleNo,
    isDefault:true
  } ];
  dialog.cfg.queueProperty("buttons", myButtons);

  dialog.render(document.body);
  dialog.show();
}

function popup(text) {
  var dialog = new YAHOO.widget.SimpleDialog("dlg", {
    width: "20em",
    fixedcenter:true,
    modal:true,
    visible:false,
    draggable:false
  });
  dialog.setHeader(I18n.t('popup.simple.title'));
  dialog.setBody(text);
  dialog.cfg.setProperty("icon", YAHOO.widget.SimpleDialog.ICON_WARN);

  var myButtons = [ {
    text: I18n.t('popup.simple.ok'),
    handler: dialog.hide,
    isDefault: true
  } ];
  dialog.cfg.queueProperty("buttons", myButtons);

  dialog.render(document.body);
  dialog.show();
}